{% extends "center/base.html" %}
{% block title %}DSS平台{% endblock %}
{% block urlName %}authorize{% endblock %}
{% block section_name %}我的订阅计划{% endblock %}
{% block main %}
 <div class="ctbox goods">
                     <div class="tit">
                         <ul class="tab">
                            <li><a href="list">已创建的订阅</a></li>
                            <li class="a">编辑</li>
                        </ul>
                     </div>
                     <div class="ctn">
                                <form action="/update" method="POST" id="addfrm">
                                <input type="hidden" name="tid"  value="{{ task.id }}" />
                                <input type="hidden" name="sid"  value="{{ task.store.id }}" />
                                 <table width="100%" border="0" align="center" >
                                  <tr>
                                    <td width="100" height="45" align="right">计划名称:</td>
                                    <td width="180" align="center">
                                        <input type="text" name="task_name"  value="{{ task.task_name }}" />
                                    </td>
                                    <td><span id="task_name_msg"></span></td>
                                  </tr>
                                    <tr>
                                        <td width="100" height="45" align="right">店铺名称:</td>
                                        <td width="180" align="center">
                                            <input type="text" name="store_name"  value="{{ store_name }}" />
                                        </td>
                                        <td><span id="store_name_msg"></span></td>
                                    </tr>
                                  <tr>
                                    <td height="45" align="right">店铺地址:</td>
                                    <td align="center">
                                        <input type="text" name="store_url"  value="{{ task.store.store_url }}" />
                                    </td>
                                    <td><span id="store_url_msg"></span></td>
                                  </tr>
                                  <tr>
                                    <td height="45" align="right">状态:</td>
                                    <td align="center">
                                        {% if task.stat %}
                                        <input type="radio" value="1" checked="checked" name="stat"/>启用
                                        <input type="radio" value="0"  name="stat"/>停用
                                         {% else %}
                                            <input type="radio" value="1"  name="stat"/>启用
                                            <input type="radio" value="0" checked="checked" name="stat"/>停用
                                        {% endif %}
                                    </td>
                                    <td></td>
                                  </tr>
                                  <tr>
                                    <td height="46" align="center"><input type="submit" value=" " id="submit" style="display: none;" /></td>
                                    <td height="46" align="center"><span class="r"><a class="btn sync" href="#" id="click_submit">确定</a></span></td>
                                    <td height="46" align="center">&nbsp;</td>
                                  </tr>
                                </table>
                             </form>
                     </div>
  </div>

{% endblock %}
{% block readyfunction %}
  $("#click_submit").click(function (){
        $("#submit").trigger("click");
  });
    $('#addfrm').ajaxForm({
		//target: '#output_result',
		dataType: 'json',
		beforeSubmit: function (formData, jqForm, options){
			var _el = null;
			for(var i=0; i<formData.length; i++){
				_el = formData[i];
				if(_el.name == 'task_name'){
					if(_el.value.length < 1){
						$('#task_name_msg').html('计划名称不能为空！');
						return false;
					}
				}
				else if(_el.name == 'store_url'){
					if(_el.value.length < 1){
						$('#store_url_msg').html('店铺地址不能为空！');
						return false;
					}
				}
                else if(_el.name == 'store_name'){
					if(_el.value.length < 1){
						$('#store_name_msg').html('店铺名称不能为空！');
						return false;
					}
				}
				else if(_el.name == 'stat'){
					if(_el.value.length < 1){
						//$('#validateCode_result').html('验证码必须为4位！');
						return false;
					}
				}
			}
			return true;
		},
		success: function (data){

                alert(data.msg);

		}
	});
{% endblock %}
{% block headarea %}
    <script type="text/javascript" src="http://agent.happy001.com/js/jquery.form.js"></script>
{% endblock %}